<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="/WEB-INF/tld/ce.tld" prefix="ce"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/sys/menu/";  //应用的地址名
//重要：数据对象表唯一标识，由于页面都是加载到主框架的，所以为避免加载的不同页面中出现相同的对象或者方法名产生冲突，故统一在这些名称后加上uuid以标示唯一性。避免js错误
String uuid = com.ce.framework.util.GeneratorUUID.generateUUID();  
String treeName = request.getParameter("treeName");   //菜单树的名称
String viewAreaName = request.getParameter("viewAreaName");  //菜单查看区域的id名称
String addActionName = basePath+"SysMenu_add.action";   //菜单添加界面
String editActionName = basePath+"SysMenu_modify.action";  //菜单修改界面
String delActionName = basePath+"SysMenu_del.action?op=deljs";           //菜单删除地址
String viewActionName = basePath + "SysMenu_look.action";  //菜单查看界面
%>
<script type="text/javascript">
<!--
$(function(){
 //=======================面板初始化===================================
	$('#menu<%=uuid%>').panel({
	  title: '菜单设置：<s:property value="#request.menu.vcName" />',
	  fit: true
	});
//=========================按钮初始化===================================	
	$('#modify<%=uuid %>').linkbutton({
	   iconCls:"icon-save"
	});
	$('#del<%=uuid %>').linkbutton({
	   iconCls:"icon-cancel"
	});
	$('#add<%=uuid %>').linkbutton({
	   iconCls:"icon-add"
	});
	$('#refresh<%=uuid%>').linkbutton({
	   iconCls:"icon-reload"
	});
//===========================按钮事件===============================	
    //修改操作
	$('#modify<%=uuid %>').click(function(){
	   <s:if test="#request.po.intLevel==0"> 
          defaultOpenWindow('<%=editActionName%>?viewAreaName=<%=viewAreaName%>&treeName=<%=treeName%>&chkSelf=<s:property value="#request.menu.vcId"/>','修改记录',650,430,'','',{but:[{id:'add',name:'添加新操作',classname:'icon-add'},{id:'save',name:'保存',classname:'icon-save'}]});
       </s:if>
       <s:else>
          defaultOpenWindow('<%=editActionName%>?viewAreaName=<%=viewAreaName%>&treeName=<%=treeName%>&chkSelf=<s:property value="#request.menu.vcId"/>','修改记录',650,230,'','',{but:[{id:'add',name:'添加新操作',classname:'icon-add'},{id:'save',name:'保存',classname:'icon-save'}]});
       </s:else>   
	});
	//删除操作
	$('#del<%=uuid %>').click(function(){
        $.messager.confirm('警告', '您确定要删除所选菜单吗?<br><font color="red">提示：该操作将删除所选菜单及其所有子菜单！</font>', function(r){
		    if (r){
			  	   jQuery.post("<%=delActionName%>",{chkSelf:'<s:property value="#request.menu.vcId"/>'}, function(data){
			   		 try{
				            jsonReStr = jQuery.parseJSON(data);  //获取从服务器得到的数据反馈信息
				            if(jsonReStr.opState=="success"){    //操作成功处理
					            $.util.showTip({content:'数据删除成功！'});
					            //将删除的节点在菜单树中进行删除
					            var node = $('#<s:property value="#parameters.treeName"/>').tree('getSelected');  
						        $('#<s:property value="#parameters.treeName"/>').tree('remove', node.target);
                                //删除菜单后转向根菜单的查看页面
						        $('#<%=viewAreaName%>').load("<%=viewActionName%>?chkSelf=0&viewAreaName=<%=viewAreaName%>&treeName=<%=treeName%>");
				            }else{
				               $.messager.alert('消息提示','操作处理失败！原因如下：<br><font color=red>'+jsonReStr.opInfo+'</font>','error');
				            }
			            }catch(e){
			               $.messager.alert('消息提示','出现系统错误!可能原因如下：<br><font color=red>'+this.url+'页面地址未找到！</font>','error');
			            }
	          });  		
			}
		});
	});
	//添加下级菜单操作
	$('#add<%=uuid %>').click(function(){
          //默认的打开编辑界面操作（窗口高度，窗口宽度，编辑页面地址）
          defaultOpenAddPageHavebtn('<%=addActionName%>?viewAreaName=<%=viewAreaName%>&treeName=<%=treeName%>&pid=<s:property value="#request.menu.vcId"/>',650,430,'添加记录','','',{but:[{id:'add',name:'添加新操作',classname:'icon-add'},{id:'addBtn',name:'保存',classname:'icon-save'}]});
	});
	//刷新菜单树
	$('#refresh<%=uuid%>').click(function(){
        location.reload(); 
	});
});


//-->
</script>
<style>
<!--
.tb_add_th td{width:70%;word-break: break-all; word-wrap:break-word;}
-->
</style>
<div id="menu<%=uuid%>" style="padding:1px;" align="center" >    
    <table style="width:100%"  class="tb_add_th">
        <tr><th style="width:20%">菜单名称：</th><td><s:property value="#request.menu.vcName"/></td></tr>
        <tr><th>菜单URL：</th><td><s:property value="#request.menu.vcUrl"/></td></tr>
        <tr><th>参数配置：</th><td><s:property value="#request.menu.vcMemo"/></td></tr>
        <tr><th>排序号：</th><td><s:property value="#request.menu.intSeq"/></td></tr>
        <tr><th>是否为子系统：</th><td><s:if test='%{#request.menu.vcIsMerge == "0"}'>否</s:if><s:else>是</s:else></td></tr>
   </table>     
<s:if test="#request.po.intLevel==0">    
<div style="width:100%; float:left; text-align:center; margin-top:5px" align="center">    
<table class="tb_list_gen" style="width:100%;height:auto; float:left"  align="center">
   <caption>菜单功能项</caption>
    <thead>
        <tr>
            <th width="40">排序</th>
            <th width="80" norowp="true">操作名称</th>
            <th width="80">操作简写</th>
            <th width="80">函数名称</th>
            <th width="80">按钮名称</th>
            <th width="80">图标</th>
        </tr>
    </thead>
    <tbody>
    <s:iterator value="#request.searchResultData" status="operate">
        <tr>
            <td><s:property value="nseq"/></td>
            <td><s:property value="vcName"/></td>
            <td><s:property value="vcSimpleName"/></td>
            <td><s:property value="vcFunname"/></td>
            <td><s:property value="vcIdname"/></td>
            <td><s:property value="vcIco"/></td>
        </tr>
   </s:iterator>    
    </tbody>
</table>   
</div>
</s:if>
<table style="width:100%; float:left; margin-top:5px"  align="right">
<tr><td>
<ce:includeColum optName="modify" menuUrl="/ntax/sys/menu/SysMenu.action">
<a id="modify<%=uuid %>" href="javascript:void(0)" class="easyui-linkbutton" >修改</a>
</ce:includeColum>
<ce:includeColum optName="del" menuUrl="/ntax/sys/menu/SysMenu.action">
<a id="del<%=uuid %>" href="javascript:void(0)" class="easyui-linkbutton" >删除</a>
</ce:includeColum>
<ce:includeColum optName="add" menuUrl="/ntax/sys/menu/SysMenu.action">
<a id="add<%=uuid %>" href="javascript:void(0)" class="easyui-linkbutton" >增加下级</a>
</ce:includeColum>
<a id="refresh<%=uuid %>" href="javascript:void(0)" class="easyui-linkbutton" >刷新</a>
</td></tr>
</table>
</div>
